In [ ]:
#Create a variable that will ask you for the text you will convert.
message = input("Convert a message to binary")
#Create an empty variable that will contain the binary digits.
binary = ""
#Create a For loop that will convert each letter in the text you are converting.
for letter in message:
    #Create a variable that will give you the ascii code in decimal of the character, it’s ordinal “ord()”
    a = ord(letter)
    #Create a variable that will convert the ordinal to binary “bin()”
    b = bin(a)
    #Take the first two characters(0b) off of the binary variable “[2:]”
    b = b[2:]
    #Place a leading “0” in front of the of the binary variable (1000001 becomes 01000001)
    b = "0" + b
    #If the length of the binary variable is still less than 8 digits
    if len(b) < 8:
        #Place a leading “0” in front of the of the binary variable (0100001 becomes 00100001) so it is 8 digits wide
        b = "0" + b
    #Add the character to the empty variable you created in step two.
    binary += b
    #Print the whole message.
print(binary)
In [ ]: